<template>
	<view class="login reset">
		<view class="login-from-wrap">
			<van-cell-group class="login-from">
				<van-field
					type="number"
					clearable
					:border="false"
					@change="cName"
					use-button-slot
					placeholder="请输入真实姓名"
				></van-field>
				<van-field
					clearable
					:border="false"
					@change="cIdCards"
					placeholder="请输入身份证号码"
					:error-message="error"
				>
				</van-field>
				<van-field
					type="number"
					clearable
					:border="false"
					@change="cBankCard"
					placeholder="请输入银行卡号"
					:error-message="error"
				>
				</van-field>

			</van-cell-group>
			<view :class="{ active: active }">
				<van-button
					size="large"
					custom-class="login-from-btn"
					:loading="loading"
					@click="onLogin"
				>
					保存
				</van-button>
			</view>
		</view>
	</view>
</template>

<script>
import * as reg from '../../common/utils/reg.js';
export default {
	data() {
		return {
			loading: false,
			active: false,
			from: {
				userName: '',
				IdCards: '',
				bankCard: ''
			},
			verify: {
				userName: false,
				IdCards: false,
				bankCard: false
			},
			error: '',
		};
	},
	onLoad() {},
	methods: {
		onLogin() {
			const arr = Object.values(this.verify)
			console.log(arr)
			if (arr.indexOf(false) > -1) {}
			console.log(arr.indexOf(false))
			//this.loading = true;
		},
		goLogin() {
			uni.navigateTo({
				url: '/pages/user/login/index'
			})
		},
		cName (e) {
			this.verify.userName = reg.regName (e.detail).bool;
			if (this.verify.userName ) this.from.userName = e.detail;
			this.ifVerif()
		},
		cIdCards (e) {
			this.verify.IdCards  = reg.regIdCards(e.detail).bool;
			if (this.verify.IdCards ) this.from.IdCards  = e.detail;
			this.ifVerif()
		},
		cBankCard (e) {
			this.verify.bankCard = reg.regBankCard(e.detail).bool;
			if (this.verify.bankCard) this.from.bankCard = e.detail;
			this.ifVerif()
		},
		ifVerif () {
			const arr = Object.values(this.verify);
			const data = arr.indexOf(false) > -1;
			return data ? this.active = false : this.active = true;
		}
	}
};
</script>

<style scoped lang="scss">
.register {
	padding-bottom: 130upx;
	.login-from-wrap {
		margin: 90upx 50upx 0 50upx;
	}
}
.login {
	&-title {
		padding-top: 6vh;
		font-size: 40upx;
		font-weight: 700;
		text-align: center;
	}
	&-from {
		margin: auto;
		&-wrap {
			margin: 120upx 50upx 0 50upx;
		}
		.van-button::before {
			content: ' ';
			border-color: #e6e6e6;
			background-color: #e6e6e6;
		}
	}
	&-jump {
		display: flex;
		justify-content: space-between;
		margin: 40upx 10upx 0 10upx;
		color: #0079f3;
		font-size: 26upx;
		line-height: 1;
	}
}
</style>
